<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ page import="br.com.constant.Action" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 thansitional//EN" "http://www.w3.org/th/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<script type="text/javascript">
		function sendValorFinal(value, linha){
			window.location.href="VendasAction?linha=" + linha + "&value=" + value + "&action=<%= Action.UPVALFIN %>";
		}
	</script>
<title>Vendas</title>
</head>
<body>

<table>
	<tr>
		<th>Codigo Produto</th>
		<th>Nome Produto</th>
		<th>Valor Produto</th>
		<th>Qtd Produto</th>
		<th>Valor Total</th>
		<th>Valor Final</th>
		<th>Excluir</th>
	</tr>
	<c:forEach var="item" items="${listaProdutos}" varStatus="linha">
		<tr>
			<td><c:out value="${item.produto.id}" /></td>
			<td><c:out value="${item.produto.descricao}" /></td>
			<td><c:out value="${item.produto.valor}" /></td>
			<td><a href="VendasAction?linha=<c:out value="${linha.index}" />&action=<%= Action.QTD %>&value=MIN">&lsaquo;</a>&nbsp;<c:out value="${item.quantidade}" />&nbsp;<a href="VendasAction?linha=<c:out value="${linha.index}" />&action=<%= Action.QTD %>&value=MAX">&rsaquo;</a></td>
			<td><c:out value="${item.valorTotal}" /></td>
			<td><input type="text" value="<c:out value="${item.valorFinal}" />" onchange="sendValorFinal(value, <c:out value="${linha.index}" />)" /></td>
			<td><a href="VendasAction?linha=<c:out value="${linha.index}" />&action=<%= Action.RMV %>">X</a></td>
		</tr> 
    </c:forEach>
   	<tr>
		<td>Total</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td>&nbsp;</td>
		<td><c:out value="${total}" /></td>
	</tr>  		
</table>

</body>
</html>